
package com.yuan.hibernate;

import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * A data access object (DAO) providing persistence and search support for 请假申请
 * entities. Transaction control of the save(), update() and delete() operations
 * can directly support Spring container-managed transactions or they can be
 * augmented to handle user-managed Spring transactions. Each of these methods
 * provides additional information for how to configure it for the desired type
 * of transaction control.
 * 
 * @see com.yuan.hibernate.请假申请
 * @author MyEclipse Persistence Tools
 */
@SuppressWarnings("rawtypes")
public class 请假申请DAO extends BaseHibernateDAO {
    private static final Logger log = LoggerFactory.getLogger(请假申请DAO.class);
    // property constants
    public static final String _填表人 = "填表人";
    public static final String _申请人 = "申请人";
    public static final String _姓名 = "姓名";
    public static final String _所属队室 = "所属队室";
    public static final String _请假类别 = "请假类别";
    public static final String _总时间 = "总时间";
    public static final String WILLREAD = "willread";
    public static final String READED = "readed";
    public static final String _请假理由 = "请假理由";
    public static final String _意见 = "意见";
    public static final String _状态 = "状态";

    public void save(请假申请 transientInstance) {
        log.debug("saving 请假申请 instance");
        try {
            getSession().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }

    public void delete(请假申请 persistentInstance) {
        log.debug("deleting 请假申请 instance");
        try {
            getSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }

    public 请假申请 findById(java.lang.Integer id) {
        log.debug("getting 请假申请 instance with id: " + id);
        try {
            请假申请 instance = (请假申请) getSession()
                    .get("com.yuan.hibernate.请假申请", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }

    public List findByExample(请假申请 instance) {
        log.debug("finding 请假申请 instance by example");
        try {
            List results = getSession()
                    .createCriteria("com.yuan.hibernate.请假申请")
                    .add(Example.create(instance))
                    .list();
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List findByProperty(String propertyName, Object value) {
        log.debug("finding 请假申请 instance with property: " + propertyName
                + ", value: " + value);
        try {
            String queryString = "from 请假申请 as model where model."
                    + propertyName + "= ?";
            Query queryObject = getSession().createQuery(queryString);
            queryObject.setParameter(0, value);
            return queryObject.list();
        } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
        }
    }

    public List findBy填表人(Object 填表人
            ) {
        return findByProperty(_填表人, 填表人);
    }

    public List findBy申请人(Object 申请人
            ) {
        return findByProperty(_申请人, 申请人);
    }

    public List findBy姓名(Object 姓名
            ) {
        return findByProperty(_姓名, 姓名);
    }

    public List findBy所属队室(Object 所属队室
            ) {
        return findByProperty(_所属队室, 所属队室);
    }

    public List findBy请假类别(Object 请假类别
            ) {
        return findByProperty(_请假类别, 请假类别);
    }

    public List findBy总时间(Object 总时间
            ) {
        return findByProperty(_总时间, 总时间);
    }

    public List findByWillread(Object willread
            ) {
        return findByProperty(WILLREAD, willread);
    }

    public List findByReaded(Object readed
            ) {
        return findByProperty(READED, readed);
    }

    public List findBy请假理由(Object 请假理由
            ) {
        return findByProperty(_请假理由, 请假理由);
    }

    public List findBy意见(Object 意见
            ) {
        return findByProperty(_意见, 意见);
    }

    public List findBy状态(Object 状态
            ) {
        return findByProperty(_状态, 状态);
    }

    public List findAll() {
        log.debug("finding all 请假申请 instances");
        try {
            String queryString = "from 请假申请";
            Query queryObject = getSession().createQuery(queryString);
            return queryObject.list();
        } catch (RuntimeException re) {
            log.error("find all failed", re);
            throw re;
        }
    }

    public 请假申请 merge(请假申请 detachedInstance) {
        log.debug("merging 请假申请 instance");
        try {
            请假申请 result = (请假申请) getSession()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(请假申请 instance) {
        log.debug("attaching dirty 请假申请 instance");
        try {
            getSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(请假申请 instance) {
        log.debug("attaching clean 请假申请 instance");
        try {
            getSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
}
